'''
Created on 18/09/2011

@author: godinho
'''

class Street :
    '''
    classdocs
    '''

    def __init__(self, streetName, cEdge):
        '''
        Constructor
        '''
        
        #Street name, this value is used as street ID
        self._name = streetName
        
        #Actual queue size, initialized with -1 that means this value was
        #not initialized
        self._queueSize = -1
        
        #Actual street flow, initialized with -1 that means this values was
        #not initialized
        self._flow = -1
        
        #Number of street lanes
        self._lanes = list()
        
        #Stores a reference to a C++ object that represents an edge on 
        #netowork.
        self._cobject = cEdge
        
    def addLane(self, laneId):
        self._lanes.append(laneId)
        
    def containsLane(self, laneId):
        return laneId in self._lanes
    
    def getLanes(self):
        return self._lanes
    
    def addToFlow(self, value):
        self._flow += value
        
    def setQueue(self, size):
        self._queueSize = size
        
    def resetFlow(self):
        self._flow = 0
        
    def getFlow(self):
        return self._flow
        
    def resetQueue(self):
        self._queueSize = 0
        
    def getCObject(self):
        return self._cobject
    
    def collectData(self, time):
        self._cobject.setFlush(self._flow)
        self._cobject.setQueue(self._queueSize)
        
    def __str__(self):
        return "Street : {{name : {0}, queueSize : {1}, flow : {2}, lanes : {3}}}".format(self._name, self._queueSize, self._flow, self._lanes)
        
        